void a(vector<TH1 *> &v, TObject *h){ v.push_back((TH1 *)h); }
void chi2dcx(){
  TFile *f = new TFile(getenv("TMP1"), "UPDATE");
  TTree *etf = (TTree *)f->Get("etf");
  vector<TH1 *> v;
  TH1 *h0;
  char zcut[64] = "";
  static const int Z = 29;
  if(Z > 0) sprintf(zcut, "az0>%.2f && az0<%.2f", Z-0.5, Z+0.5);

  const char xuv[3] = {'X', 'U', 'V'};
  char hname[64]{}, ly[64]{};
  int id = 0;
  for(int i = 0; i < 3; i++){ // loop over dc0-1-2
    for(int j = 0; j < 1; j++){ // loop over X-U-V, limited to X only here
      for(int k = 0; k < 2; k++){ // loop over X(U,V)0-1
        sprintf(ly, "dc%d%c%d", i, xuv[j], k);
        sprintf(hname, "h%s", ly);
        h0 = new TH2F(hname, Form("chi-t of %s", ly), 500, -100., 400., 500, -3., 3.);
        h0->GetXaxis()->SetTitle("drift time of X0 [ns]");
        h0->GetYaxis()->SetTitle("tracking \\chi [mm]");
        string cut = Form("%s && %s.fired()>=2", zcut, ly); // 2: normal trking; 3: global trking
        etf->Project(hname, Form("%s.GetChi():%s.GetT()", ly, ly), cut.data());
        a(v, h0); // a(vrt, h1);
        cout << "Processing " << ly << ": " << zcut << "...\r" << flush;
      } // end for over k
    } // end for over x,u,v
  } // end for over dcs

  TCanvas *c = new TCanvas("c", "Tracking \\chi v.s. Drift Time of dcs", 1680, 1050);
  c->Divide(2, 3);
  for(int i = 0; i < 6; i++){
    c->cd(i+1);
    v[i]->Draw("colz");
  } // end for
  c->Print("chi2dcx.pdf");
} // end vis
